package com.cnhis.cloudhealth.clidoctorweb.clidoctor;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;

import org.apache.commons.codec.digest.DigestUtils;
import org.jboss.resteasy.logging.Logger;
import org.springframework.stereotype.Component;
import org.springframework.ui.Model;

import com.alibaba.dubbo.config.annotation.Reference;
import com.cnhis.cloudhealth.clinical.clidoctor.clidoctor.service.ICliDoctor;
import com.cnhis.cloudhealth.clinical.clidoctor.patientsearch.service.IPatientSearch;
import com.cnhis.cloudhealth.commons.Mappers.ModelVo;
import com.cnhis.cloudhealth.commons.commonSql.service.ICommonSql;
import com.cnhis.cloudhealth.commons.interceptor.CLoginFilter;
import com.cnhis.cloudhealth.commons.interceptor.SpringContextHolder;
import com.cnhis.cloudhealth.commons.redisdb.RedisResource;
import com.cnhis.cloudhealth.commons.utils.JsonUtil;
import com.cnhis.cloudhealth.commons.utils.StaticKeys;

@Path("clidoctor")
@Component
public class CliDoctorRest
{
    Logger log = Logger.getLogger(CliDoctorRest.class);
    
    @Reference
    private ICliDoctor cliDoctor;
    @Reference
    private IPatientSearch patientSearch;
    @Reference
    private ICommonSql commonSql;
    private RedisResource redisResource = (RedisResource) SpringContextHolder.getBean("redisResource");
    private static Lock locks = new ReentrantLock();

    /* ScriptId(7254) */
    /* Description(提取医师聘任职务) */
    /**
     * 
     * @param BCE01 员工id
     * @return
     * @throws Exception
     */
    @POST
    @Path("getdoctorposition")
    @Produces({MediaType.APPLICATION_JSON})
    @SuppressWarnings("unchecked")
    public ModelVo getDoctorPosition(@FormParam("BCE01") int BCE01)
        throws Exception
    {
        HashMap map = new HashMap();
        map.put("BCE01", BCE01);
        return cliDoctor.getDoctorPosition(map);
    }
    
    /**
     * 存储过程:Nurse_Lis_Bills_Print
     * @param BCE01 员工id
     * @return
     * @throws Exception
     */
    @POST
    @Path("nurse_Lis_Bills_Print")
    @Produces({MediaType.APPLICATION_JSON})
    @SuppressWarnings("unchecked")
    public ModelVo nurse_Lis_Bills_Print(@FormParam("bce03") String bce03,@FormParam("cbm01Arr") String cbm01Arr)
        throws Exception
    {
        try
        {
            locks.lock();
            HashMap map = new HashMap();
            map.put("bce03", bce03);
            map.put("cbm01Arr", cbm01Arr);
            return cliDoctor.nurse_Lis_Bills_Print(map);
        }finally {
            locks.unlock();
        }
        
    }
    
    /**
     * 存储过程:Nurse_Lis_Bills_Print_batch
     * @param BCE01 员工id
     * @return
     * @throws Exception
     */
    @POST
    @Path("nurse_Lis_Bills_Print_batch")
    @Produces({MediaType.APPLICATION_JSON})
    @SuppressWarnings("unchecked")
    public ModelVo nurse_Lis_Bills_Print_batch(@FormParam("bce03") String bce03,@FormParam("cbm01Arr") String cbm01Arr,@FormParam("vbq1") String vbq1)
        throws Exception
    {
        String value = cliDoctor.getParameter(9999, 9999, 111);
        if("1".equals(value)) 
        {
            if (!"[]".equals(cbm01Arr))
            {
                HashMap map = new HashMap();
                try
                {
                    locks.lock();
                    map.put("bce03", bce03);
                    map.put("cbm01Arr", cbm01Arr);
                    map.put("vbq1", vbq1);
                    return cliDoctor.nurse_Lis_Bills_Print_batch(map);
                }
                finally
                {
                    locks.unlock();
                } 
            }
            else 
            {
                ModelVo mo = new ModelVo();
                mo.setResult(StaticKeys.OH_SUCCESS);
                return mo;
            }
        }
        else 
        {
            if (!"[]".equals(cbm01Arr))
            {
                HashMap map = new HashMap();
                map.put("bce03", bce03);
                map.put("cbm01Arr", cbm01Arr);
                map.put("vbq1", vbq1);
                return cliDoctor.nurse_Lis_Bills_Print_batch_T(map);
            }
            else 
            {
                ModelVo mo = new ModelVo();
                mo.setResult(StaticKeys.OH_SUCCESS);
                return mo;
            }
        }
        
        
    }
    
    /**
     * 
     */
    @GET
    @Path("getGeiyaoZhixing")
    @Produces({MediaType.APPLICATION_JSON})
    @SuppressWarnings("unchecked")
    public ModelVo getGeiyaoZhixing(@QueryParam("bbx01") long bbx01)
        throws Exception
    {
        HashMap map = new HashMap();
        map.put("bbx01", bbx01);
        return cliDoctor.getGeiyaoZhixing(map);
    }
    
    /**
     * 预扣库存处理rest
     */
    /*@POST
    @Path("updateDpt1")
    @Produces({MediaType.APPLICATION_JSON})
    @SuppressWarnings("unchecked")
    public ModelVo updateDpt1(@FormParam("dpt1Arr") String dpt1Arr)
        throws Exception
    {
        HashMap map = new HashMap();
        map.put("dpt1Arr", dpt1Arr);
        return cliDoctor.updateDpt1(map);
    }*/
    
    /**
     * 门诊医生系统新开界面加载redis数据
     */
    @GET
    @Path("getRedisResource")
    @Produces({MediaType.APPLICATION_JSON})
    public ModelVo getRedisResource()
        throws Exception
    {
        String[] arr = {"abb1","zhixingxingzhi_mz","bbx1_zhongyaoyongfa_mz","acx1_zhongyaojiaozhu_mz","bbx1_zhongyaojianfa_mz","bdi1_zhongyao_pinci_mz",
            "bbx1_fujiashoushu_mz","bbx1_mazui_mz","bdi1_xiyao_pinci_mz","biw1_yongyaomudi_mz","bce1_shoushurenyuan_mz","bdi1_qitapinci_mz","cag1_jibing_mz","bbx1_geiyaotujing_mz"};
        ModelVo mv = new ModelVo();
        try
        {
            Map<String,Object> temp = new HashMap<String, Object>();
            for(String key : arr)
            {
                temp.put(key, redisResource.getRedisList(key));
            }
            mv.setMap(temp);
            mv.setResult(StaticKeys.OH_SUCCESS);
        }
        catch (Exception e)
        {
            mv.setResult(StaticKeys.OH_FALSE);
            e.printStackTrace();
        }
        return mv;
    }
    
    /**
     * 根据bce01查询bce03
     */
    @GET
    @Path("getBce03")
    @Produces({MediaType.APPLICATION_JSON})
    @SuppressWarnings("unchecked")
    public ModelVo getBce03(@QueryParam("bce01") int bce01)
        throws Exception
    {
        HashMap map = new HashMap();
        map.put("bce01", bce01);
        return cliDoctor.getBce03(map);
    }
    
    /**
     * 查询医院编码
     */
    @GET
    @Path("getHccode")
    @Produces({MediaType.APPLICATION_JSON})
    @SuppressWarnings("unchecked")
    public ModelVo getHccode(@QueryParam("yiyuanId") int yiyuanId)
        throws Exception
    {
        HashMap map = new HashMap();
        map.put("yiyuanId", yiyuanId);
        return cliDoctor.getHccode(map);
    }
    
    
    /**
     * 简易挂号界面下拉框rest服务
     */
    @GET
    @Path("selectDataByScriptId")
    @Produces({MediaType.APPLICATION_JSON})
    @SuppressWarnings("unchecked")
    public ModelVo selectDataByScriptId(@QueryParam("ID") int ID,@QueryParam("paramStr") String paramStr)
        throws Exception
    {
        HashMap map = new HashMap();
        map.put("ID", ID);
        map.put("paramStr", paramStr);
        return commonSql.selectDataByScriptId(map);
    }
    
    /**
     * 简易挂号界面下拉框rest服务
     */
    @GET
    @Path("selectDataByScriptId1")
    @Produces({MediaType.APPLICATION_JSON})
    @SuppressWarnings("unchecked")
    public ModelVo selectDataByScriptId1(@QueryParam("ID") int ID,@QueryParam("paramStr") String paramStr,@QueryParam("rows") int rows,@QueryParam("page") int page)
        throws Exception
    {
        HashMap map = new HashMap();
        map.put("ID", ID);
        map.put("paramStr", paramStr);
        map.put("rows", rows);
        map.put("page", page);
        return cliDoctor.selectDataByScriptId1(map);
    }
    
    /**
     * 保存页面设置
     * 
     * @param ID
     * @param paramStr
     * @param page
     * @param rows
     * @return
     * @throws Exception
     */
    @SuppressWarnings({ "rawtypes", "unchecked" })
    @POST
    @Path("/SavedOneUserParameters")
    @Produces(MediaType.APPLICATION_JSON)
    public ModelVo SavedOneUserParameters(@FormParam("grid2rows") String grid2rows) throws Exception {
        Map paramMap = new HashMap();
        paramMap.put("grid2rows", grid2rows);
        ModelVo mv = commonSql.SavedOneUserParameters(paramMap);
        mv.setResult(StaticKeys.SUCCESS);
        return mv;
    }
    
    @SuppressWarnings("unchecked")
    @POST
    @Path("/HORate_CardCharge_Update")
    @Produces(MediaType.APPLICATION_JSON)
    public ModelVo exec_CardCharge_Update(
        @FormParam("VAA01") long VAA01,
        @FormParam("VAA07") long VAA07,
        @FormParam("VAI01") long VAI01,
        @FormParam("ACF01") int ACF01,
        @FormParam("BCE01") int BCE01,
        @FormParam("BCK01") int BCK01,
        @FormParam("BCE02") String BCE02,
        @FormParam("VAJ38") double VAJ38,
        @FormParam("AType") int AType,
        @FormParam("AWorkType") int AWorkType
        ) throws Exception 
    {
        Map paramMap = new HashMap();
        paramMap.put("VAA01", VAA01);
        paramMap.put("VAA07", VAA07);
        paramMap.put("VAI01", VAI01);
        paramMap.put("ACF01", ACF01);
        paramMap.put("BCE01", BCE01);
        paramMap.put("BCK01", BCK01);
        paramMap.put("BCE02", BCE02);
        paramMap.put("VAJ38", VAJ38);
        paramMap.put("AType", AType);
        paramMap.put("AWorkType", AWorkType);
        ModelVo mv = cliDoctor.exec_CardCharge_Update(paramMap);
        mv.setResult(StaticKeys.SUCCESS);
        return mv;
    }
    
    /**
	 * 获取门诊号
	 * @return
     * @throws Exception 
	 */

	@GET
	@Path("/getvaa03")
	@Produces(MediaType.APPLICATION_JSON)
	public ModelVo horategetvaa03() throws Exception{
		ModelVo mv = cliDoctor.horategetvaa03();
		if(mv.getResult().equals(StaticKeys.OH_FALSE)){
			return mv;
		}
    	return mv;
	}

	@SuppressWarnings({ "rawtypes", "unchecked" })
    @GET
    @Path("/commonQuery")
    @Produces(MediaType.APPLICATION_JSON)
    public ModelVo commonQuery(@QueryParam("ID") Integer ID, @QueryParam("paramStr") String paramStr, @QueryParam("page") Integer page, @QueryParam("rows") Integer rows,	@QueryParam("sidx") String sidx,
			@QueryParam("sord") String sord) throws Exception {
        Map paramMap = new HashMap();
        paramMap.put("ID", ID);
        paramMap.put("paramStr", paramStr);
        paramMap.put("page", page);
        paramMap.put("rows", rows);
    	paramMap.put("sidx", sidx);
		paramMap.put("sord", sord);
        ModelVo mv = commonSql.commonQuery(paramMap);
        return mv;
    }
	
	@GET
	@Path("/queryBce1Info")
	@Produces(MediaType.APPLICATION_JSON)
	public ModelVo queryBce1Info(@QueryParam("bck01") Integer bck01) throws Exception {
	    Map paramMap = new HashMap();
	    paramMap.put("bck01", bck01);
	    ModelVo mv = cliDoctor.queryBce1Info(paramMap);
	    return mv;
	}
	
	@GET
	@Path("/queryJibingByText")
	@Produces(MediaType.APPLICATION_JSON)
	public ModelVo queryJibingByText(@QueryParam("txt") String txt) throws Exception {
	    Map paramMap = new HashMap();
	    paramMap.put("txt", txt);
	    ModelVo mv = cliDoctor.queryJibingByText(paramMap);
	    return mv;
	}
	
	@GET
	@Path("/aab1")
	@Produces(MediaType.APPLICATION_JSON)
	public ModelVo aab1() throws Exception {
	    return cliDoctor.aab1();
	}
    
	@GET
	@Path("/getAllYiyuanInfo")
	@Produces(MediaType.APPLICATION_JSON)
	public ModelVo getYiyuanInfo() throws Exception {
	    return cliDoctor.getYiyuanInfo();
	}
	
	/* ScriptId(817) */
	/** Description(草药方剂：根据方剂id检索草药组成明细) */
	@GET
	@Path("/script817")
	@Produces(MediaType.APPLICATION_JSON)
	public ModelVo script817(@QueryParam("bbx01a") String bbx01a) throws Exception {
	    Map paramMap = new HashMap();
	    paramMap.put("bbx01a", bbx01a);
	    return cliDoctor.script817(paramMap);
	}
	
	/**
	 * 根据会员卡号查新病人信息
	 * @return
	 * @throws Exception
	 */
	@GET
	@Path("/queryVac1ByVcb")
	@Produces(MediaType.APPLICATION_JSON)
	public ModelVo queryVac1ByVcb(@QueryParam("vbu03") String vbu03) throws Exception {
	    Map paramMap = new HashMap();
	    paramMap.put("vbu03", vbu03);
	    return cliDoctor.queryVac1ByVcb(paramMap);
	}
	
	/**
     * 获取加密密码
     * @return
     * @throws Exception
     */
    @GET
    @Path("/getMD5PassWord")
    @Produces(MediaType.APPLICATION_JSON)
    public Map getMD5PassWord(@QueryParam("password") String password) throws Exception {
        if(password == null){
           password = "";
        }
        String pass = DigestUtils.md5Hex(password);
        Map teMap = new HashMap<>();
        teMap.put("pass", pass);
        return teMap;
    }
    /**
     * 获取加密密码
     * @return
     * @throws Exception
     */
    @GET
    @Path("/queryFileInfoByType")
    @Produces(MediaType.APPLICATION_JSON)
    public ModelVo queryFileInfoByType() throws Exception {
        Map teMap = new HashMap<>();
        return cliDoctor.queryFileInfoByType(teMap);
    }
    
    @GET
    @Path("/queryHasZj")
    @Produces(MediaType.APPLICATION_JSON)
    public ModelVo queryHasZj(@QueryParam("vac01") long vac01,@QueryParam("hours") int hours) throws Exception
    {
        Map<String,Object> teMap = new HashMap<String,Object>();
        teMap.put("vac01",vac01);
        teMap.put("hours",hours);
        return cliDoctor.queryHasZj(teMap);
    }
    
    @GET
    @Path("/queryZjList")
    @Produces(MediaType.APPLICATION_JSON)
    public ModelVo queryZjList() throws Exception
    {
        Map<String,Object> teMap = new HashMap<String,Object>();
        return cliDoctor.queryZjList(teMap);
    }

	
    /**
     * 门诊医生系统主入口
     */
    @SuppressWarnings("rawtypes")
    @POST
    @Path("main")
    public void main(@Context HttpServletRequest request,@Context HttpServletResponse response) throws Exception
    {
        Map map = (Map)patientSearch.findSysparams1(new HashMap()).getList().get(0);
        String num = map.get("value").toString();
        request.setAttribute("num", num);
        String url = "http://"+request.getServerName()+":"+request.getServerPort()+"/"+request.getServletContext().getServletContextName()+"/"+num+"/main.jsp";
        response.sendRedirect(url);
    }
    
    @GET
    @Path("/queryZhentaiConfig")
    @Produces(MediaType.APPLICATION_JSON)
    public ModelVo queryZhentaiConfig(@QueryParam("bck01") int bck01) throws Exception
    {
        Map<String,Object> teMap = new HashMap<String,Object>();
        teMap.put("bck01", bck01);
        return cliDoctor.queryZhentaiConfig(teMap);
    }
    
    @POST
    @Path("/savePatientMore")
    @Produces(MediaType.APPLICATION_JSON)
    public ModelVo savePatientMore(@FormParam("vaa07") long vaa07,
                                    @FormParam("vaa01") long vaa01,
                                    @FormParam("vac63") double vac63,
                                    @FormParam("vcj04") double vcj04,
                                    @FormParam("vcj05") double vcj05) throws Exception
    {
        Map<String,Object> teMap = new HashMap<String,Object>();
        teMap.put("vaa07", vaa07);
        teMap.put("vaa01", vaa01);
        if (vac63!=0.0)
        {
            teMap.put("vac63", vac63);
        }
        if (vcj04!=0.0)
        {
            teMap.put("vcj04", vcj04);
        }
        if (vcj05!=0.0)
        {
            teMap.put("vcj05", vcj05);
        }
        return cliDoctor.savePatientMore(teMap);
    }

    
    @POST
    @Path("/selecthuiyuanbingren")
    @Produces(MediaType.APPLICATION_JSON)
    public ModelVo selecthuiyuanbingren(@FormParam("context") String context,
                                        @FormParam("pageSize") int pageSize,
                                        @FormParam("currentPage") int currentPage) throws Exception
    {
        Map<String,Object> teMap = new HashMap<String,Object>();
        teMap.put("context", context);
        return cliDoctor.selecthuiyuanbingren(teMap, currentPage, pageSize);
    }
    
    @GET
    @Path("/querybas02Bybce01")
    @Produces(MediaType.APPLICATION_JSON)
    public ModelVo querybas02Bybce01(@QueryParam("bce01") String bce01) throws Exception
    {
        Map<String,Object> teMap = new HashMap<String,Object>();
        teMap.put("bce01", bce01);
        return cliDoctor.querybas02Bybce01(teMap);
    }
    
    @GET
    @Path("/querybbx20Byvaf01")
    @Produces(MediaType.APPLICATION_JSON)
    public ModelVo querybbx20Byvaf01(@QueryParam("vaf01") long vaf01) throws Exception
    {
        Map<String,Object> teMap = new HashMap<String,Object>();
        teMap.put("vaf01", vaf01);
        return cliDoctor.querybbx20Byvaf01(teMap);
    }
    
    @POST
    @Path("/updateBas1_bce1")
    @Produces(MediaType.APPLICATION_JSON)
    public ModelVo updateBas1_bce1(@FormParam("bas01") String bas01,@FormParam("bce01") int bce01) throws Exception
    {
        Map<String,Object> teMap = new HashMap<String,Object>();
        teMap.put("bas01", bas01);
        teMap.put("bce01", bce01);
        return cliDoctor.updateBas1_bce1(teMap);
    }
    
    
    @GET
    @Path("/hujiao_houtai")
    @Produces(MediaType.APPLICATION_JSON)
    public ModelVo hujiao_houtai(@QueryParam("searchcondition") String searchCondition,@QueryParam("vac01") String vac01,
        @QueryParam("searchvalue") String searchValue, @QueryParam("lVAC51") Integer lVAC51,@QueryParam("fenzhen") int fenzhen,
        @QueryParam("aday") Integer aDay, @QueryParam("lPara") String lPara, @QueryParam("lBCK01") Integer lBCK01,
        @QueryParam("beginTime") String beginTime, @QueryParam("endTime") String endTime,@QueryParam("vad01") int vad01,
        @QueryParam("lBCE01") Integer lBCE01, @QueryParam("BAS02") String BAS02, @QueryParam("aDate") String aDate,
        @QueryParam("lSign") Integer lSign,@QueryParam("lBCE02") String lBCE02,@QueryParam("lBCE03") String lBCE03,@QueryParam("zhenjinVajList") String zhenjinVajList) throws Exception
    {
        HashMap hs = new HashMap();
        hs.put("vac01", vac01);
        hs.put("lVAC51", lVAC51);
        hs.put("lPara", lPara);
        hs.put("lBCK01", lBCK01);
        hs.put("lBCE01", lBCE01);
        hs.put("lBCE02", lBCE02);
        hs.put("lBCE03", lBCE03);
        hs.put("BAS02", BAS02);
        hs.put("fenzhen", fenzhen);
        hs.put("aDate", aDate);
        Calendar calendarB = Calendar.getInstance(); 
        Calendar calendarA = Calendar.getInstance(); //得到日历
        Date date = new Date();
        Date dBefore = date;
        Date dAfter = date;
        calendarB.setTime(dBefore);
        calendarA.setTime(dAfter);
        switch (beginTime)
        {
            case "0":
                calendarB.add(Calendar.DAY_OF_MONTH, -1);  
                break;
            case "1":
                calendarB.add(Calendar.DAY_OF_MONTH, -1);  
                calendarA.add(Calendar.DAY_OF_MONTH, -2);  
                break;
            case "2":
                calendarB.add(Calendar.DAY_OF_MONTH, -2);  
                calendarA.add(Calendar.DAY_OF_MONTH, -3);  
                break;
            default:
                calendarB.add(Calendar.DAY_OF_MONTH, -1);  
                break;
        }
        
        dBefore = calendarB.getTime();   
        dAfter = calendarA.getTime();   
        String date1 = new SimpleDateFormat("yyyy-MM-dd 23:40:00").format(dBefore);
        String date2 = new SimpleDateFormat("yyyy-MM-dd 23:59:59").format(dAfter);
        hs.put("beginTime", date1);
        hs.put("endTime", date2);
        hs.put("searchcondition", searchCondition);
        hs.put("searchvalue", searchValue);
        hs.put("vad01", vad01);
        hs.put("lSign", lSign);
        hs.put("zhenjinVajList", zhenjinVajList);
        try
        {
            return cliDoctor.hujiao_houtai(hs);
        }
        catch (Exception e)
        {
            e.printStackTrace();
            ModelVo mv = new ModelVo();
            String message=e.getMessage();
            if(message.contains("@"))
            {
                message = message.substring(e.getMessage().indexOf(":")).substring(message.indexOf(":")+1, message.indexOf("@"));
                mv.setResultMsg(message);
            }
            mv.setResultMsg("保存失败，请查看日志");
            mv.setResult(StaticKeys.OH_FALSE);
            return mv;
        }
    }
    
    @POST
    @Path("/updateVaj1")
    @Produces(MediaType.APPLICATION_JSON)
    public ModelVo updateVaj1(@FormParam("params") String params) throws Exception
    {
        Map<String,Object> teMap = new HashMap<String,Object>();
        teMap = JsonUtil.getMap(params);
        return cliDoctor.updateVaj1(teMap);
    }
    
    @POST
    @Path("/updateVaa15ByVac01")
    @Produces(MediaType.APPLICATION_JSON)
    public ModelVo updateVaa15ByVac01(@FormParam("params") String params) throws Exception
    {
        Map<String,Object> teMap = new HashMap<String,Object>();
        teMap = JsonUtil.getMap(params);
        return cliDoctor.updateVaa15ByVac01(teMap);
    }
    
    /**
     * 查询病人已经生成的诊金项目
     * @param params
     * @return
     * @throws Exception
     */
    @GET
    @Path("/querySendZjByvac01")
    @Produces(MediaType.APPLICATION_JSON)
    public ModelVo querySendZjByvac01(@QueryParam("params") String params) throws Exception
    {
        Map<String,Object> teMap = new HashMap<String,Object>();
        teMap = JsonUtil.getMap(params);
        return cliDoctor.querySendZjByvac01(teMap);
    }
    
    /**
     * 查询医生的自定义诊断
     * @param params
     * @return
     * @throws Exception
     */
    @GET
    @Path("/queryBce1_vao1")
    @Produces(MediaType.APPLICATION_JSON)
    public ModelVo queryBce1_vao1(@QueryParam("params") String params) throws Exception
    {
        Map<String,Object> teMap = new HashMap<String,Object>();
        teMap = JsonUtil.getMap(params);
        return cliDoctor.queryBce1_vao1(teMap);
    }
    
    /**
     * 查询联系人家庭关系
     * @param params
     * @return
     * @throws Exception
     */
    @GET
    @Path("/queryFamilyRelation")
    @Produces(MediaType.APPLICATION_JSON)
    public ModelVo queryFamilyRelation(@QueryParam("params") String params) throws Exception
    {
        Map<String,Object> teMap = new HashMap<String,Object>();
        teMap = JsonUtil.getMap(params);
        return cliDoctor.queryFamilyRelation(teMap);
    }
    
    /**
     * 查询医生对应的诊金
     * @param params
     * @return
     * @throws Exception
     */
    @GET
    @Path("/queryAah1Bby1ByBce01")
    @Produces(MediaType.APPLICATION_JSON)
    public ModelVo queryAah1Bby1ByBce01(@QueryParam("params") String params) throws Exception
    {
        Map<String,Object> teMap = new HashMap<String,Object>();
        teMap = JsonUtil.getMap(params);
        return cliDoctor.queryAah1Bby1ByBce01(teMap);
    }
    
    /**
     * 查询病人对应的眼科信息
     * @param params
     * @return
     * @throws Exception
     */
    @GET
    @Path("/queryEye1")
    @Produces(MediaType.APPLICATION_JSON)
    public ModelVo queryEye1(@QueryParam("params") String params) throws Exception
    {
        Map<String,Object> teMap = new HashMap<String,Object>();
        teMap = JsonUtil.getMap(params);
        return cliDoctor.queryEye1(teMap);
    }
    
    
    /**
     * 保存病人对应的眼科信息
     * @param params
     * @return
     * @throws Exception
     */
    @GET
    @Path("/saveEye1")
    @Produces(MediaType.APPLICATION_JSON)
    public ModelVo saveEye1(@QueryParam("params") String params) throws Exception
    {
        Map<String,Object> teMap = new HashMap<String,Object>();
        teMap = JsonUtil.getMap(params);
        return cliDoctor.saveEye1(teMap);
    }
    
    /**
     * 修改病人对应的眼科信息
     * @param params
     * @return
     * @throws Exception
     */
    @GET
    @Path("/updateEye1")
    @Produces(MediaType.APPLICATION_JSON)
    public ModelVo updateEye1(@QueryParam("params") String params) throws Exception
    {
        Map<String,Object> teMap = new HashMap<String,Object>();
        teMap.put("ykList", JsonUtil.getList(params));
        return cliDoctor.updateEye1(teMap);
    }
    
    /**
     * 批量更新医生的自定义诊断
     * @param params
     * @return
     * @throws Exception
     */
    @POST
    @Path("/updateBce01_vao1")
    @Produces(MediaType.APPLICATION_JSON)
    public ModelVo updateBce01_vao1(@FormParam("params") String params) throws Exception
    {
        Map<String,Object> teMap = new HashMap<String,Object>();
        teMap = JsonUtil.getMap(params);
        return cliDoctor.updateBce01_vao1(teMap);
    }
    
    /**
     * 获取服务器时间
     * @param params
     * @return
     * @throws Exception
     */
    @GET
    @Path("/querySysTime")
    @Produces(MediaType.APPLICATION_JSON)
    public ModelVo querySysTime() throws Exception
    {
        return cliDoctor.querySysTime();
    }
    
    @POST
    @Path("/updateVajZjByvaj01")
    @Produces(MediaType.APPLICATION_JSON)
    public ModelVo updateVajZjByvaj01(@FormParam("params") String params) throws Exception
    {
        Map<String,Object> teMap = new HashMap<String,Object>();
        teMap = JsonUtil.getMap(params);
        return cliDoctor.updateVajZjByvaj01(teMap);
    }
    
    /**
     * 修改常用项目
     * @param params
     * @return
     * @throws Exception
     */
    @POST
    @Path("/updateBdj1ByBce01AndBbx01")
    @Produces(MediaType.APPLICATION_JSON)
    public ModelVo updateBdj1ByBce01AndBbx01(@FormParam("params") String params) throws Exception
    {
        Map<String,Object> teMap = new HashMap<String,Object>();
        teMap = JsonUtil.getMap(params);
        return cliDoctor.updateBdj1ByBce01AndBbx01(teMap);
    }
    
    /**
     * 删除常用项目
     * @param params
     * @return
     * @throws Exception
     */
    @POST
    @Path("/deleteBdj1ByBce01AndBbx01")
    @Produces(MediaType.APPLICATION_JSON)
    public ModelVo deleteBdj1ByBce01AndBbx01(@FormParam("params") String params) throws Exception
    {
        Map<String,Object> teMap = new HashMap<String,Object>();
        teMap = JsonUtil.getMap(params);
        return cliDoctor.deleteBdj1ByBce01AndBbx01(teMap);
    }
    
    /**
     * 获取客户端的ip和mac
     */
    @GET
    @Path("/getIpAndMac")
    @Produces(MediaType.APPLICATION_JSON)
    public ModelVo getIpAndMac(@QueryParam("params") String params,@Context HttpServletRequest request) throws Exception
    {
        Map<String,Object> teMap = new HashMap<String,Object>();
//        teMap = JsonUtil.getMap(params);
        ModelVo mv = new ModelVo();
        try
        {
            String ip = CLoginFilter.getIpAddress(request);
            String mac = CLoginFilter.getMACAddress(ip);
            Map<String,Object> temp = new HashMap<String,Object>();
            temp.put("ip", ip);
            temp.put("mac", mac);
            mv.setMap(temp);
            mv.setResult(StaticKeys.OH_SUCCESS);
            return mv;
        }
        catch (Exception e)
        {
            e.printStackTrace();
            mv.setResultMsg(e.toString());
            mv.setResult(StaticKeys.OH_FALSE);
            return mv;
        }
    }
    
    
    
    
    
    
}
